Hi friends, |
Re: unique array determination bool fPutSkipIncrement(Skip skpList, string KeyValue) { // Insert the KeyValue into the Skip list's 'Key'. // The 'Data' portion of the Skip is set to 1 for new inserts and is // incremented for already existing 'Key's in the Skip. // 'Data' MUST be of type Integer. // (represents the number of references). // Return whether this is a first insert for KeyValue into the Skip. bool IsNewValue = false int NumReferences = 0 // Remains zero if next "find" doesn't find anything: if(find(skpList, KeyValue, NumReferences)) delete(skpList, KeyValue) // Remove It else IsNewValue = true // Mark it New // ReInsert new or updated counts NumReferences++ put (skpList, KeyValue, NumReferences) return(IsNewValue) } // end fPutSkipIncrement() // ========== MAIN ============= string arr[7]={"Apple","orange","orange","pineapple","Apple","Apple","orange"} int i, Count string Fruit Skip skpTotals = createString() // KEY 'string' fruit; DATA 'int' count for (i=0; i<sizeof(arr); i++) { fPutSkipIncrement(skpTotals, arr[i]) } for Count in skpTotals do { Fruit = (string key skpTotals) print Count "\t" Fruit "\n" } delete(skpTotals) |
Re: unique array determination llandale - Mon Nov 19 15:02:37 EST 2012 Oops
//*********************
bool fPutSkipIncrement(Skip skpList, string KeyValue)
{ // Insert the KeyValue into the Skip list's 'Key'.
// The 'Data' portion of the Skip is set to 1 for new inserts and is
// incremented for already existing 'Key's in the Skip.
// 'Data' MUST be of type Integer.
// (represents the number of references).
// Return whether this is a first insert for KeyValue into the Skip.
bool IsNewValue = false
int NumReferences = 0 // Remains zero if next "find" doesn't find anything:
if(find(skpList, KeyValue, NumReferences))
delete(skpList, KeyValue) // Remove It
else IsNewValue = true // Mark it New
// ReInsert new or updated counts
NumReferences++
put (skpList, KeyValue, NumReferences)
return(IsNewValue)
} // end fPutSkipIncrement()
string arr[7]={"Apple","orange","orange","pineapple","Apple","Apple","orange"}
int i, Count
string Fruit
Skip skpTotals = createString() // KEY 'string' fruit; DATA 'int' count
for (i=0; i<sizeof(arr); i++)
{ fPutSkipIncrement(skpTotals, arr[i])
}
for Count in skpTotals do
{ Fruit = (string key skpTotals)
print Count "\t" Fruit "\n"
}
delete(skpTotals)
|
Re: unique array determination llandale - Mon Nov 19 15:03:32 EST 2012 Oops
//*********************
bool fPutSkipIncrement(Skip skpList, string KeyValue)
{ // Insert the KeyValue into the Skip list's 'Key'.
// The 'Data' portion of the Skip is set to 1 for new inserts and is
// incremented for already existing 'Key's in the Skip.
// 'Data' MUST be of type Integer.
// (represents the number of references).
// Return whether this is a first insert for KeyValue into the Skip.
bool IsNewValue = false
int NumReferences = 0 // Remains zero if next "find" doesn't find anything:
if(find(skpList, KeyValue, NumReferences))
delete(skpList, KeyValue) // Remove It
else IsNewValue = true // Mark it New
// ReInsert new or updated counts
NumReferences++
put (skpList, KeyValue, NumReferences)
return(IsNewValue)
} // end fPutSkipIncrement()
string arr[7]={"Apple","orange","orange","pineapple","Apple","Apple","orange"}
int i, Count
string Fruit
Skip skpTotals = createString() // KEY 'string' fruit; DATA 'int' count
for (i=0; i<sizeof(arr); i++)
{ fPutSkipIncrement(skpTotals, arr[i])
}
for Count in skpTotals do
{ Fruit = (string key skpTotals)
print Count "\t" Fruit "\n"
}
delete(skpTotals)
|